﻿using System;
using System.ComponentModel;

namespace BuildExplorer
{
    public enum DateFilterType
    {
        [Description("Today")]            Today,
        [Description("Last 24 hours")]    Last24Hours,
        [Description("Last 48 hours")]    Last48Hours,
        [Description("Last 7 days")]      Last7Days,
        [Description("Last 14 days")]     Last14Days,
        [Description("Last 28 days")]     Last28Days,
        [Description("<Any Time>")]       AnyTime,
    }    

    static class DateFilterTypeExtensions
    {
        public static DateTime GetMinFinishTime(this DateFilterType t)
        {
            switch (t)
            {
                case DateFilterType.Today: return DateTime.Today;
                case DateFilterType.Last24Hours: return DateTime.Now.Subtract(TimeSpan.FromHours(24));
                case DateFilterType.Last48Hours: return DateTime.Now.Subtract(TimeSpan.FromHours(48));
                case DateFilterType.Last14Days: return DateTime.Today.Subtract(TimeSpan.FromDays(14));
                case DateFilterType.Last28Days: return DateTime.Today.Subtract(TimeSpan.FromDays(28));
                case DateFilterType.Last7Days: return DateTime.Today.Subtract(TimeSpan.FromDays(7));
                case DateFilterType.AnyTime:
                default: return DateTime.MinValue;
            }
        }
    }
}
